package com.mankiw.code_generator.controller;

import com.mankiw.code_generator.entity.DataSource;
import com.mankiw.code_generator.service.IDataSourceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/dataSource")
public class DataSourceController {

    @Autowired
    IDataSourceService dataSourceService;

    @PostMapping("/add")
    public DataSource createDataSource(@RequestBody DataSource dataSource) {
        var result = dataSourceService.add(dataSource);
        return result;
    }

    @GetMapping("/getById/{id}")
    public DataSource createDataSource(@PathVariable("id") Long id) {
        var result = dataSourceService.findById(id);
        return result;
    }

}
